<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class AttractionsController extends HomeController
{    
    public function index()
    {
		$category = new \Category\Model\CategoryAttractionsList\Home\GetCategoryListModel();
		$category_list = $category->get_list();
		$this->assign('category_list', $category_list);
		/*获取轮播图*/
		$carousel = new \Document\Model\Carousel\Home\GetAttractionsCarouselModel();
		$carousel_list = $carousel->get();
		$this->assign('carousel_list', $carousel_list);
		/*获取推荐旅游路线*/
		$article = new \Document\Model\Article\Home\GetAttractionsArticleModel();
		$article_list = $article->get();
		$pid=$article_list[0]['id'];
		$document_content_article=D(DocumentContentArticle);
		$condition['id']=$pid;
		$tour_route_content=$document_content_article->where($condition)->field('content')->select();
		$this->assign('tour_route_content', $tour_route_content);
		
		$document=D('Document');
		$category_id=$_GET['id'];
		if($category_id='NULL'){
			$category_id=$category_list[0]['id'];
		}
		$where['category_id']=$category_id;
		$where['status']=1;
		$page = new \Think\Page($document->where($where)->count(),3);
        $group_lists = $document->where($where)->field('id , cover_id , title')->order("level desc,id desc")->limit($page->firstRow.','.$page->listRows)->select();
		$page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%<p id="pageTips">第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pageCount.' 条/页 共 %TOTAL_ROW% 条信息)</p>');
        $pageStyle = $page->show();
        $pageStyle = str_replace("num","jrgzlb_page_ye",$pageStyle);//替换样式
        $pageStyle = str_replace("current","jrgzlb_page_dangqian",$pageStyle);
        $this->assign('_page',$pageStyle);
		$this->assign('category_id' , $category_id);
		$this->assign('list',  $group_lists);
        $this->display('index');
    }
	
	
	 public function content()
    {
		$category = new \Category\Model\CategoryAttractionsList\Home\GetCategoryListModel();
		$category_list = $category->get_list();
		$this->assign('category_list', $category_list);
		
		$news_id=$_GET['id'];
		$information=D('DocumentInformation');
		$document=D('Document');
		$where['id']=$news_id;
		$news_title=$document->where($where)->select();
		$news_content=$information->where($where)->field('content')->select();
		$category_id=$news_title[0]['category_id'];
		$this->assign('category_id' , $category_id);
        $this->assign('news_title',  $news_title);
		$this->assign('news_content',  $news_content);
		$this->assign('list',  $group_lists);
        $this->display('content');
    }
	

}